import java.util.Arrays;

public class RearrangeArray {
    public static void main(String[] args) {
        int[] numbers = {3, 1, 4, 2, 5, 8, 6};
        System.out.println("Original array: " + Arrays.toString(numbers));

        rearrangeArray(numbers);

        System.out.println("Array after rearrangement: " + Arrays.toString(numbers));
    }

    public static void rearrangeArray(int[] array) {
        int oddCount = 0; // Count of odd numbers
        for (int i = 0; i < array.length; i++) {
            if (array[i] % 2 != 0) {
                oddCount++;
            }
        }

        int oddIndex = 0; // Index for placing the next odd number
        for (int i = 0; i < array.length; i++) {
            if (array[i] % 2 != 0) {
                array[oddIndex] = array[i];
                oddIndex++;
            }
        }
    }
}